package com.gonsin.gview.logic.config;

import com.gonsin.gview.annotations.interfaces.IGViewInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class GViewHandlerInterceptor implements HandlerInterceptor {

    @Autowired(required = false)
    private IGViewInterceptor interceptor;

    @Override
    public boolean preHandle(HttpServletRequest httpServletRequest,
                             HttpServletResponse httpServletResponse, Object handler) throws Exception {
        if(interceptor != null){
            return interceptor.preHandle(httpServletRequest, httpServletResponse, handler);
        }
        return true;
    }

}
